package com.ruimei.util;

import java.util.HashMap;

public class WebResult
  extends HashMap<String, Object>
{
  private static final long serialVersionUID = 1L;
  
  public WebResult()
  {
    put("code", Integer.valueOf(200));
  }
  
  public static WebResult ok()
  {
    return new WebResult();
  }
  
  public static WebResult ok(String msg)
  {
    WebResult result = new WebResult();
    result.put("msg", msg);
    return result;
  }
  
  public static WebResult ok(String code, String msg)
  {
    WebResult result = new WebResult();
    result.put("status", code);
    result.put("msg", msg);
    return result;
  }
  
  public static WebResult error()
  {
    return error(500, "未知错误，请稍后重试!");
  }
  
  public static WebResult error(String msg)
  {
    return error(500, msg);
  }
  
  public static WebResult error(int code, String msg)
  {
    WebResult result = new WebResult();
    result.put("code", Integer.valueOf(code));
    result.put("msg", msg);
    return result;
  }
  
  public WebResult put(String key, Object value)
  {
    super.put(key, value);
    return this;
  }
  
  public static WebResult checkResult(int dbNum)
  {
    WebResult result = new WebResult();
    if (dbNum == 1)
    {
      result.put("code", "200");
      result.put("msg", "操作成功");
      return result;
    }
    result.put("code", "500");
    result.put("msg", "操作失败");
    return result;
  }
}


/* Location:              E:\360MoveData\Users\admin\Desktop\teacher_wap-0.0.1-SNAPSHOT.jar!\BOOT-INF\classes\com\ruime\\util\WebResult.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       0.7.1
 */